package listbyorder.access001_100.test80;

import java.util.ArrayDeque;
import java.util.ArrayList;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/4 11:16
 */
public class Solution1 {

    // 方法一： 定义双指针
    public int removeDuplicates(int[] nums) {
        if(nums == null || nums.length == 0) return 0;
        int left = 0;
        int right = 0;
        int count = 0;
        int pre = nums[0];
        while (right < nums.length) {
            if (nums[right] == pre) {
                count++;
                right++;
                if (count <= 2) {
                    nums[left++] = pre;
                }
            } else {
                pre = nums[right];
                count = 0;
            }
        }
        return left;
    }

    public static void main(String[] args) {
        ArrayDeque<Integer> queue = new ArrayDeque<>();
        ArrayList<Integer> ans = new ArrayList<>();
        int[] arr = new int[10];
    }
}

